package com.iss.controller.user;

import com.google.gson.Gson;
import com.iss.model.Employee;
import com.iss.service.EmployeeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/user/list")
public class UserListServlet extends HttpServlet {
    EmployeeService service = new EmployeeService();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*
         * 集合
         *   List Set Map
         * */
        List<Employee> list = service.getList();
        Gson gson = new Gson();
        response.getWriter().println(gson.toJson(list));
    }
}
